/**
 * NotificationCase.m
 *
 * The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License");
 * you may not use this file except in compliance with the License. You may obtain a copy of the License 
 * at http://www.mozilla.org/MPL/
 * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
 * either express or implied. See the License for the specific language governing rights and limitations 
 * under the License.
 *
 * The Original Code is gcast-toolbox4iphone.
 *
 * The Initial Developers of the Original Code is Giannandrea Castaldi.
 */

#import "NotificationCases.h"
#import "GTActivityNotifier.h"

@implementation NotificationCase

+ (id)notificationCase {
  return [[[self alloc] init] autorelease];
}

- (id)initWithBlock:(BOOL(^)(int count))aBlock {
  if ((self = [super init])) {
    frequencyMaker = [[FrequencyMaker alloc] initWithTimeInterval:5.0
                                                            Block:aBlock];
  }
  return self;
}

- (id)init {
  return [self initWithBlock:^BOOL(int count) {
    return NO;
  }];
}

- (void)dealloc {
  [frequencyMaker release];
  [super dealloc];
}

@end


@implementation OneMessageNotificationCase
- (id)init {
  BOOL (^aBlock)(int count) = ^BOOL(int count) {
    BOOL result = YES;
    switch (count) {
      case 0:
        [GTActivityNotifier notifyStartActivityWithWheelInPosition:GTActivityNotifierWheelPositionUp];
        [GTActivityNotifier notifyMessage:@"Message One"];
        break;      
      case 1:
      default:
        [GTActivityNotifier notifyEndActivity];
        result = NO;
        break;
    }
    return result;
  };
  return [super initWithBlock:aBlock];
}
@end

@implementation TwoMessagesNotificationCase
- (id)init {
  BOOL (^aBlock)(int count) = ^BOOL(int count) {
    BOOL result = YES;
    switch (count) {
      case 0:
        [GTActivityNotifier notifyStartActivityWithWheelInPosition:GTActivityNotifierWheelPositionUp];
        [GTActivityNotifier notifyMessage:@"Message One"];
        break;      
      case 1:
        [GTActivityNotifier notifyMessage:@"Message Two"];
        break;      
      default:
        [GTActivityNotifier notifyEndActivity];
        result = NO;
        break;
    }
    return result;
  };
  return [super initWithBlock:aBlock];
}
@end

@implementation ThreeMessagesNotificationCase
- (id)init {
  BOOL (^aBlock)(int count) = ^BOOL(int count) {
    BOOL result = YES;
    switch (count) {
      case 0:
        [GTActivityNotifier notifyStartActivityWithWheelInPosition:GTActivityNotifierWheelPositionUp];
        [GTActivityNotifier notifyMessage:@"Message One"];
        break;      
      case 1:
        [GTActivityNotifier notifyMessage:@"Message Two"];
        break;      
      case 2:
        [GTActivityNotifier notifyMessage:@"Message Three (long), Message Three (long), Message Three (long), Message Three (long), Message Three (long), Message Three (long)"];
        break;      
      default:
        [GTActivityNotifier notifyEndActivity];
        result = NO;
        break;
    }
    return result;
  };
  return [super initWithBlock:aBlock];
}
@end

@implementation ThreeMessagesAndConfirmNotificationCase
- (id)init {
  BOOL (^aBlock)(int count) = ^BOOL(int count) {
    BOOL result = YES;
    switch (count) {
      case 0:
        [GTActivityNotifier notifyStartActivityWithWheelInPosition:GTActivityNotifierWheelPositionUp];
        [GTActivityNotifier notifyMessageToConfirm:@"Login failed, verify that email inserted is that used during registration."];
        break;      
      case 1:
        [GTActivityNotifier notifyMessage:@"This is the second message shown, a little longer."];
        break;      
      case 2:
        [GTActivityNotifier notifyMessageToConfirm:@"This is the third message shown, with a button."];
        break;      
      case 3:
        [GTActivityNotifier notifyMessageToConfirm:@"This is the fourth message shown, with a button.\nThe message is longer that the previous one."];
        break;      
      default:
        [GTActivityNotifier notifyEndActivity];
        result = NO;
        break;
    }
    return result;
  };
  return [super initWithBlock:aBlock];
}
@end

